 #include "mainwidget.h"

#include <QApplication>
#include "LoginWidget.h"

#include "model/datacenter.h"
#include "network/netclient.h"
#include "debug.h"


FILE* output = nullptr;

// 将日志打印到文件中
void msgHandler(QtMsgType type,const QMessageLogContext& context,const QString& msg)
{
    (void) type;
    (void) context;
    const QByteArray& log = msg.toUtf8();
    fprintf(output, "%s\n", log.constData());
    fflush(output);		// 确保数据落入硬盘
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

#if DEPOLY
    // 将日志进行重定向
    output = fopen("./log.txt","a");
    qInstallMessageHandler(msgHandler);
#endif

#if TEST_SKIP_LOGIN
    MainWidget* w = MainWidget::getInstance();
    w->show();
#else
    LoginWidget* loginWidget = new LoginWidget();
    loginWidget->show();
#endif

#if TEST_NETWORK
//    network::NetClient netClient(nullptr);
//    netClient.ping();

    model::DataCenter* dataCenterr = model::DataCenter::getInstance();
    dataCenterr->ping();

#endif

    return a.exec();
}
